<template>
    <div class="addaddress">
        <Head title="编辑地址" :left="true"></Head>
        <div class="sub-child">

            <van-address-edit
            :area-list="areaList"
            show-postal
            show-set-default
            show-search-result
            :search-result="searchResult"
            :area-columns-placeholder="['请选择', '请选择', '请选择']"
            @save="onSave"
            
           
            />
        </div>
    </div>
</template>

<script>
import {areaList} from '@/utils/city.js'
import { Toast } from 'vant';
export default {
    data() {
    return {
      areaList,
      searchResult:[],
      saveList:{},
    };
  },
  methods: {
   onSave(content) {
    this.saveList.mobile=localStorage.getItem('mobile');
    this.saveList.name=content.name;
    this.saveList.phone=content.tel;
    this.saveList.province=content.province;
    this.saveList.city=content.city;
    this.saveList.region=content.county;
    this.saveList.detail_addr=content.addressDetail;
    this.saveList.group_message=content.isDefault;
    this.saveList.areaCode=content.areaCode;
    console.log(this.saveList)
    this.$ajax.setAddress(this.saveList).then(res=>{
        if(res.code==200){
            Toast.success(res.msg);
        }else{
             Toast.fail(res.msg);
        }
    })
        this.$router.push({name:'address'})
    },
   
  },
}
</script>


